package com.eyaomall.wxmall.common.error;

import com.lycheeframework.core.cmp.api.error.IECode;
import com.lycheeframework.core.common.util.StringUtil;
import com.lycheeframework.core.cmp.api.annotation.Error;

public enum BECode implements IECode{
	
	/**
	 * 授权
	 */
	@Error(msg="apiKey或secretKey为空！")
	oauth_300000(300000), 
	@Error(msg="apiKey或secretKey已过期！")
	oauth_30001(300001), 
	
	/**
	 * 短信
	 */
	@Error(msg="发送短信失败！")
	sms_301000(301000), 
	@Error(msg="手机或短信内容为空！")
	sms_301001(301001), 
	@Error(msg="发送短信过于频繁，请稍后再试！")
	sms_301002(301002), 
	@Error(msg="今日短信次数超过上限！")
	sms_301003(301003), 
	@Error(msg="短信验证码已过期！")
	sms_301004(301004), 
	@Error(msg="短信验证码不存在！")
	sms_301005(301005),
	@Error(msg="短信验证码不能为空！")
	sms_301006(301006),
	
	/**
	 * 会员
	 */
	@Error(msg="手机已绑定！")
	member_100001(100001),
	@Error(msg="短信验证码不存在！")
	member_100002(100002),
	
	/**
	 * 会员
	 */
	@Error(msg="产品ids不能为空！")
	goods_200001(200001),
	@Error(msg="产品参数不正确！")
	goods_200002(200002),
	@Error(msg="订单已被删除或者下架！")
	goods_200003(200003),
	
	/**
	 * 会员
	 */
	@Error(msg="收货地址ID不能为空！")
	address_300001(300001),
	@Error(msg="收货地址不存在！")
	address_300002(300002),
	@Error(msg="收货人名称不能为空！")
	address_300003(300003),
	@Error(msg="收货人名称不能大于20个字！")
	address_300004(300004),
	@Error(msg="收货手机格式不正确！")
	address_300005(300005),
	@Error(msg="收货地址省市区不能为空！")
	address_300006(300006),
	@Error(msg="收货地址详情不能为空！")
	address_300007(300007),
	@Error(msg="收货地址详情长度不能大于60个字！")
	address_300008(300008),
	@Error(msg="邮编长度不能大于15个字！")
	address_300009(300009),
	@Error(msg="该产品不再准售范围内！")
	address_300010(300010),
	
	@Error(msg="订单ID不能为空")
	order_4000001(4000001),
	@Error(msg="砍价活动ID不能为空")
	order_4000002(4000002),
	@Error(msg="产品运费不能为空")
	order_4000003(4000003),
	@Error(msg="订单状态不正确，不可操作")
	order_4000004(4000004),
	
	@Error(msg="支付下单失败")
	pay_5000001(5000001),
	@Error(msg="支付回调，订单不存在")
	pay_5000002(5000002),
	@Error(msg="产品已被删除或者下线")
	pay_5000003(5000003),
	@Error(msg="产品库存不足")
	pay_5000004(5000004),
	@Error(msg="所需支付的金额为0")
	pay_5000005(5000005),
	
	
	@Error(msg="砍价活动不存在！")
	discount_6000001(6000001),
	@Error(msg="砍价活动已过期！")
	discount_6000002(6000002),
	@Error(msg="砍价活动未开始！")
	discount_6000003(6000003),
	@Error(msg="砍价活动未上线！")
	discount_6000004(6000004),
	@Error(msg="用户正在活动中！")
	discount_6000005(6000005),
	@Error(msg="用户已经参加过该活动！")
	discount_6000006(6000006),
	@Error(msg="记录砍价信息失败！")
	discount_6000007(6000007),
	@Error(msg="已经帮忙砍过价格了！！")
	discount_6000008(6000008),
	@Error(msg="达到砍价上限！")
	discount_6000009(6000009),
	@Error(msg="修改现价失败！")
	discount_6000010(6000010),
	
	
	@Error(msg="该商品已经收藏过！")
	collect_6100010(6100010),
	@Error(msg="收藏删除失败！")
	collect_6100011(6100011),
	
	@Error(msg="购物车产品ID不能为空！")
	shopping_chart_7000000(7000000),
	@Error(msg="购物车产品数量不能为空！")
	shopping_chart_7000001(7000001),
	@Error(msg="购物车产品库存不足！")
	shopping_chart_7000002(7000002),
	
	@Error(msg="店员账号密码不正确")
	employee_8000000(8000000),
	@Error(msg="手机号或密码不能为空")
	employee_8000001(8000001),
	@Error(msg="手机号不能为空")
	employee_8000002(8000002),
	@Error(msg="手机号不存在")
	employee_8000003(8000003),
	@Error(msg="新密码不能为空")
	employee_8000004(8000004),
	@Error(msg="旧密码不能为空")
	employee_8000005(8000005),
	@Error(msg="店铺不存在该用户")
	employee_8000006(8000006),
	@Error(msg="员工不存在")
	employee_8000007(8000007),
	@Error(msg="该手机号位置该店铺绑定")
	employee_8000008(8000008),
	@Error(msg="该手机号所属门店不存在或者已经删除")
	employee_8000009(8000009),
	
	/**
	 * 优惠券
	 */
	@Error(msg="优惠券不存在")
	coupon_8100000(8100000),
	@Error(msg="优惠券不在使用范围")
	coupon_8100001(8100001),
	@Error(msg="优惠券数据不正确，请联系管理员")
	coupon_8100002(8100002),
	@Error(msg="消费金额不够优惠券的使用上限")
	coupon_8100003(8100003),
	@Error(msg="优惠券已经领取")
	coupon_8100004(8100004),
	@Error(msg="优惠券已过期")
	coupon_8100005(8100005),
	@Error(msg="优惠券还未发布")
	coupon_8100006(8100006),
	
	
	/**
	 * 物流
	 */
	@Error(msg="没有物流信息")
	logistics_8200001(8200001),
	@Error(msg="物流信息异常")
	logistics_8200002(8200002),
	
	
	
	/**
	 * 全局
	 */
	@Error(msg="手机格式不正确！")
	global_900000(900000), 
	@Error(msg="传入的参数为空！")
	global_900001(900001), 
	@Error(msg="上传失败！")
	global_900002(900002),
	@Error(msg="获取图片地址失败！")
	global_900003(900003), 
	@Error(msg="数据不存在！")
	global_900004(900004), 
	@Error(msg="数据转换错误！")
	global_900005(900005), 
	@Error(msg="省市区不存在！")
	global_900006(900006),
	@Error(msg="备注长度过长！")
	global_900007(900007),
	@Error(msg="请先登录")
	global_900008(900008),
	@Error(msg="该图片地址路径不正确！")
	global_900009(900009);
	
	
	private int code;
	
	BECode(int code) {
		this.code = code;
	}
	
	public int getCode() {
		
		return code;
	}
	
	private String getName() {
		
		return this.name();
	}

	/**
	 * 返回错误信息
	 * @return
	 */
	public String getMessage() {
		Error error = null;
		try {
			error = this.getClass().getField(getName()).getAnnotation(Error.class);
		} catch (Exception e) {
			
			return null;
		}
		
		return error.msg();
	}
	
	/**
	 * 
	 */
	@Override
	public String toString() {
		String message = this.getMessage();

		return String.valueOf(this.getCode()).concat(SPLIT_CHAR).concat((StringUtil.isBlank(message)?"":message));
	}
	
	/**
	 * 返回错误码+动态错误信息
	 * @return
	 */
	@Override
	public String toDynamicString(Object...parameters) {
		
		return String.format(this.toString(), parameters);
	}
}
